Skip to content

Fix anisotropic ibl bend factor#24515

Open
issam3105 wants to merge 1 commit into
bevyengine:mainfrom
issam3105:Fix_anisotropic_IBL_bend_factor
Open

Fix anisotropic ibl bend factor#24515
issam3105 wants to merge 1 commit into
bevyengine:mainfrom
issam3105:Fix_anisotropic_IBL_bend_factor

Conversation

@issam3105
Copy link
Copy Markdown
Contributor

@issam3105 issam3105 commented Jun 2, 2026

Objective

Fix incorrect anisotropic IBL normal bending for KHR_materials_anisotropy.

The previous formula computed 2^(2^x) instead of the x^4 bend factor described by the glTF anisotropy reference implementation. This caused anisotropy to affect areas where the anisotropy texture strength should be zero, visibly producing square texture bounds in assets such as Khronos AnisotropyDiscTest.

Solution

Replace the incorrect nested pow expression with the explicit fourth-power bend factor used by the Khronos glTF Sample Viewer

Testing

Reviewers can visually test this with the Khronos AnisotropyDiscTest and CompareAnisotropy.

Showcase

Before this PR

image

After

image

Ref Khronos

image

Before

image

After

image

Ref Khronos
(In this asset, KHR_texture_transform is applied to the normal map, so the normal detail may not line up exactly with the Khronos viewer even after the anisotropy bend factor is fixed)

image

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 2, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Jun 2, 2026
@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Shaders This code uses GPU shader languages labels Jun 2, 2026
Copy link
Copy Markdown
Contributor

@olukowski olukowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the original code assumed pow(a, b) computes b^a, which isn't the case. I was briefly thinking about whether something like:

let bendFactor = 1.0 - anisotropy * (1.0 - roughness);
bent_normal = normalize(mix(bent_normal, N, pow(bendFactor, 4.0)));

would make more sense, but then I realized plain multiplication is probably faster.

So looks good!

@IceSentry IceSentry added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Shaders This code uses GPU shader languages D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants